import java.util.Random;
import java.util.concurrent.*;

public class OneFuture {

    public static void main(String[] args) {
        ExecutorService service= Executors.newFixedThreadPool(10);
        Future<Integer> future=service.submit(new CallAbleTask());
        try {
            Integer integer = future.get();
            boolean b = future.cancel(false);
            if(!b){
                System.out.println(integer);
            }
            System.out.println(b);
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }

    }
}

class CallAbleTask implements Callable<Integer> {

    @Override
    public Integer call() throws Exception {
        Thread.sleep(3000);
        return new Random().nextInt();
    }
}
